package c.x.jy.bean.event.listener;

import java.util.Map;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;

import c.x.jy.bean.event.SmsSendEvent;
import c.x.jy.common.utils.SMSUtil;
import c.x.jy.common.utils.SmsConfig;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class OrderSmsListener {

	
	@SuppressWarnings("unchecked")
	@Async
	@EventListener
	public void paySuccess(SmsSendEvent  smsSendEvent) {
		System.out.println(JSON.toJSONString(smsSendEvent));
		System.out.println("发送订单短信"); 
	//	OrderEntity ordre =orderEvent.getData();
	//	EventPublisher.publishEvent(new OrderLogEvent( ));
		  Map<String,Object> map=		(Map<String,Object>) smsSendEvent.getData();
 	SMSUtil.send(map.get("phone").toString(), map.get("SmsCode").toString(), (Map<String,String>)map.get("params"), (SmsConfig)map.get("smsConfig"));
	}
}
